//可视化反馈得分   不再调用该js文件

var Assignment
var orderClassname=[]
window.onload = function() { 
	var $_REQUEST = new Object, aParams = unescape(document.location.search.substr(1)).split("&");
	Assignment=JSON.parse(aParams)
	
	
	$.ajax({
			async:false,
			url : '/pad/reflection/getClassInfo',
			success : function(data) {
				for(var i=0;i<data.length;i++){
					for(var j=0;j<data.length;j++){
						if(data[j][5]==i){
							if(data[j][2]!="其他"){
							orderClassname.push(data[j][2])
							}
						}
					}
				}
		    }
		});
	
	
	
	
	
	getRftItemScoreInfo(Assignment)
	};
	


function getRftItemScoreInfo(assignment){
	$.ajax({
		   url: "/pad/experiment/getRftItemScoreInfo",
		   type: 'POST',
		   data:Assignment,
		   async: false,
		   dataType: "json", //返回数据格式为json
		   success: function(data) {//请求成功完成后要执行的方法
		   var className=data.className 
		   var xLabel=orderClassname //横轴  反思类别名称
		   var score=data.score
		   var scores=[]
		   var serisData=[]
		   for (var key in score) {  
			   scores.push(score[key])
		   }
		   var dataMap={}
		   var datalegend=['正向反馈','负向反馈']
           for(var i=0;i<datalegend.length;i++){
        	   var axisData=xLabel
        	   var boxData=[]
        	   if(datalegend[i]=="正向反馈"){//构建 正向的盒子数据  
        		   for(var k=0;k<axisData.length;k++){
	        		   for(var j=0;j<scores.length;j++){
	        				   if(scores[j][1]=="1"&&scores[j][0]==axisData[k]){
	            				   var valueData=[]
	            				   valueData.push(Number(scores[j][2]))
	                			   valueData.push(Number(scores[j][3]))
	                			   valueData.push(Number(scores[j][4]))
	                			   boxData.push(valueData)
	            			   }   
	        			   }
        		   }
        		  
        	   }else{
        		   for(var k=0;k<axisData.length;k++){
	        		   for(var j=0;j<scores.length;j++){
	        				   if(scores[j][1]=="0"&&scores[j][0]==axisData[k]){
	            				   var valueData=[]
	            				   valueData.push(Number(scores[j][2]))
	                			   valueData.push(Number(scores[j][3]))
	                			   valueData.push(Number(scores[j][4]))
	                			   boxData.push(valueData)
	            			   }   
	        			   }
	        		   }
        	      }
        	   serisData.push(echarts.dataTool.prepareBoxplotData(boxData))
           } 
           var resData=[]
           for(var i=0;i<datalegend.length;i++){
        	   for(var j=0;j<serisData.length;j++){
        		   if(serisData[j].dirName==datalegend[i]){
        			   resData.push({
                           name: datalegend[i],
                           type: 'boxplot',
                           data: serisData[j].boxData,
                           tooltip:{formatter: formatter}
                       });   
        		   }
        	   }
           }            
		// Generate data.
          
		   var myChart = echarts.init(document.getElementById('main'));
		   option = {
		       title: {
		           text: '反馈正负性',
		           left: 'center',
		       },
		       legend: {
		           top: '10%',
		           data:datalegend,
		       },
		       tooltip: {
		           trigger: 'item',
		           axisPointer: {
		               type: 'shadow'
		           }
		       },
		       grid: {
		           left: '10%',
		           top: '20%',
		           right: '10%',
		           bottom: '15%'
		       },
		       xAxis: {
		    	   type: 'category',
		           data:xLabel,
		           boundaryGap: true,
		           nameGap: 30,
		           splitArea: {
		               show: true
		           },
		           axisLabel: {
		               formatter:'{value}'
		           },
		           splitLine: {
		               show: false
		           }
		       },
		       yAxis: {
		           type: 'value',
		           name: 'Value',
		           min: -10,
		           max: 10,
		           splitArea: {
		               show: false
		           }
		       },
		       dataZoom: [
		           {
		               type: 'inside',
		               start: 0,
		               end: 20
		           },
		           {
		               show: true,
		               height: 20,
		               type: 'slider',
		               top: '90%',
		               xAxisIndex: [0],
		               start: 0,
		               end: 20
		           }
		       ],
		       series:resData
		   };  
		    // 使用刚指定的配置项和数据显示图表。
		    myChart.setOption(option);
		   }
	 });
	$("#jiazai").hide()
	
}

function formatter(param) {
   	alert(1)
   	console.log(param)
   	alert(2)
       return [
           '最大值: ' + param.data[0],
           '平均值: ' + param.data[1],
           '最小值: ' + param.data[2]
       ].join('<br/>');
}
 


				